package com.newbe.service;

import com.newbe.entity.User;
import com.newbe.repository.UserDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

/**
 * @Auther: Newbe
 * @Date: 2019/9/24 23:53
 * @Description:
 */
@Service
public class UserServiceImpl implements  UserService{

    @Autowired
    private UserDAO userDAO;

    @Override
    public Optional<User> getUserById(Integer id) {
        return userDAO.findById(id);
    }

    @Override
    public List<User> getUserAll() {
        return userDAO.findAll();
    }

    @Override
    public void del(int id) {
         userDAO.deleteById(id);
    }

    @Override
    public User save(User user) {
        userDAO.save(user);
        return user;
    }
}
